<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$setting=$this->plugin_setting('basic');
$return['banner']=$setting['hdps'];
$return['setting']=$setting;
if($_RQ['op']=='main'){
	set_html('title','首页');
	$return['post']=array();
	$return['list']=array();
	$return['sharedata']=array(
		'title'=>$setting['share_title'],
		'desc'=>$setting['share_desc'],
		'link'=>custom_url('jy_dzs/index/main',true),
		'imgUrl'=>tomedia($setting['share_image']),
	);
	exi($return);
}
if($_RQ['op']=='grouplist'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>'1');
	if($_RQ['keyword']){
		$params['title like']='%'.trim($_RQ['keyword']).'%';
	}
	$params['parentid']=intval($_RQ['id']);
	//状态为显示的所有活动，排序
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_dzs_group',$params,array($pindex,$psize),$total,$fields,'','paixu desc');
	if($list){
		foreach($list as &$item){
			$item['image']=tomedia($item['image']);
			$item['listnum']=pdo_count('jy_dzs_tiku_zu',array('uniacid'=>$_SESSION['uniacid'],'groupid'=>$item['id']));
		}
	}
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>'1');
	if($_RQ['keyword']){
		$params['title like']='%'.trim($_RQ['keyword']).'%';
	}
	if($_RQ['groupid']){
		$params['groupid']=intval($_RQ['groupid']);
	}
	//状态为显示的所有活动，排序
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_dzs_list',$params,array($pindex,$psize),$total,$fields,'','createtime desc');
	if($list){
		foreach($list as &$item){
			$item['createtime']=date('Y-m-d H:i:s', $item['createtime']);
			$item['images']=json_decode($item['images'],true);
			$item['picsnum']=count($item['images']);
		}
	}
	$return['list']=$list;
	exi($return);
}